var _authorize = _interopRequireDefault(require("../public/utils/authorize"));

function _interopRequireDefault(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

function _slicedToArray(e, n) {
    return _arrayWithHoles(e) || _iterableToArrayLimit(e, n) || _nonIterableRest();
}

function _nonIterableRest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance");
}

function _iterableToArrayLimit(e, n) {
    var t = [], r = !0, o = !1, i = void 0;
    try {
        for (var a, c = e[Symbol.iterator](); !(r = (a = c.next()).done) && (t.push(a.value), 
        !n || t.length !== n); r = !0) ;
    } catch (e) {
        o = !0, i = e;
    } finally {
        try {
            r || null == c.return || c.return();
        } finally {
            if (o) throw i;
        }
    }
    return t;
}

function _arrayWithHoles(e) {
    if (Array.isArray(e)) return e;
}

function _objectSpread(n) {
    for (var e = 1; e < arguments.length; e++) {
        var t = null != arguments[e] ? arguments[e] : {}, r = Object.keys(t);
        "function" == typeof Object.getOwnPropertySymbols && (r = r.concat(Object.getOwnPropertySymbols(t).filter(function(e) {
            return Object.getOwnPropertyDescriptor(t, e).enumerable;
        }))), r.forEach(function(e) {
            _defineProperty(n, e, t[e]);
        });
    }
    return n;
}

function _defineProperty(e, n, t) {
    return n in e ? Object.defineProperty(e, n, {
        value: t,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[n] = t, e;
}

var originchooseImage = wx.chooseImage, originchooseAddress = wx.chooseAddress, originPreviewImage = wx.previewImage, originMakePhoneCall = wx.makePhoneCall, originOpenLocation = wx.openLocation, originAddPhoneContact = wx.addPhoneContact, originNavigateToMiniProgram = wx.navigateToMiniProgram, baseConfig = {
    configurable: !0,
    enumerable: !0,
    writable: !0
};

Object.defineProperties(wx, {
    chooseImage: _objectSpread({}, baseConfig, {
        value: function(e) {
            wx.interruptPush = !0, originchooseImage(e);
        }
    }),
    chooseAddress: _objectSpread({}, baseConfig, {
        value: function(e) {
            wx.interruptPush = !0, originchooseAddress(e);
        }
    }),
    previewImage: _objectSpread({}, baseConfig, {
        value: function(e) {
            wx.interruptPush = !0, originPreviewImage(e);
        }
    }),
    makePhoneCall: _objectSpread({}, baseConfig, {
        value: function(e) {
            wx.interruptPush = !0, originMakePhoneCall(e);
        }
    }),
    openLocation: _objectSpread({}, baseConfig, {
        value: function(e) {
            wx.interruptPush = !0, originOpenLocation(e);
        }
    }),
    addPhoneContact: _objectSpread({}, baseConfig, {
        value: function(e) {
            wx.interruptPush = !0, originAddPhoneContact(e);
        }
    }),
    navigateToMiniProgram: _objectSpread({}, baseConfig, {
        value: function(e) {
            var n = e.success;
            e.success = function() {
                console.group("跳转小程序成功"), console.log("appid：", e.appId), console.log("path：", e.path), 
                "function" == typeof n && n.apply(void 0, arguments);
            }, originNavigateToMiniProgram(e);
        }
    })
}), wx.fPromise = function(r) {
    for (var o = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {}, e = arguments.length, i = new Array(2 < e ? e - 2 : 0), n = 2; n < e; n++) i[n - 2] = arguments[n];
    return new Promise(function(n, t) {
        var e;
        o.success = function(e) {
            return n(e);
        }, o.fail = function(e) {
            return t(e);
        }, (e = wx)[r].apply(e, [ o ].concat(i));
    });
}, wx.setTimeout = function(e, n) {
    var t = setTimeout(function() {
        "function" == typeof e && e(), clearTimeout(t);
    }, n);
    return t;
}, wx.sleep = function(n) {
    return new Promise(function(e) {
        return wx.setTimeout(e, n);
    });
}, wx.sleepSync = function(e) {
    for (var n = Date.now(); Date.now() - n < e; ) ;
}, wx.successTip = function() {
    var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {}, n = e.title, t = e.image, r = e.success, o = e.duration, i = void 0 === o ? 600 : o, a = e.icon, c = void 0 === a ? "success" : a;
    wx.showToast({
        title: n,
        duration: i,
        icon: c,
        image: t
    }), wx.setTimeout(r, i);
}, wx.errorTip = function(e) {
    wx.showToast({
        title: e,
        duration: 800,
        image: "/images/warning-circle.png"
    });
}, wx.lazyFetch = function(e) {
    var n = e.selector, t = void 0 === n ? "" : n, r = e.scope, o = void 0 === r ? wx : r, i = e.margins, a = void 0 === i ? {} : i, c = e.handler, u = void 0 === c ? function() {} : c, s = e.disconnect, l = void 0 === s || s, f = o === wx ? getCurrentPages().slice(-1)[0] : o;
    f.$$observer = f.$$observer || {}, f.$$observer[t] && f.$$observer[t].disconnect();
    var g = f.$$observer[t] = o.createIntersectionObserver();
    return g.relativeToViewport(a).observe(t, function(e) {
        var n = 0 === Object.keys(a).length ? e.intersectionRatio : e.boundingClientRect.top;
        l ? 0 <= n && (l && g.disconnect(), u()) : u(e);
    }), g;
}, wx.get = function(e, n, r) {
    if (null === e || null === n || "string" != typeof n) return r;
    var t = n.split("."), a = [].concat(t);
    return t.forEach(function(e, n) {
        if (/^(\w+)\[(\w+)\]$/.test(e)) {
            var t = _slicedToArray(e.match(/^(\w+)\[(\w+)\]$/), 3), r = t[1], o = t[2], i = a.indexOf(e);
            a.splice(i, 1, r, o);
        }
    }), a.reduce(function(e, n) {
        if (!e) return e;
        var t = e[n] || r;
        return t instanceof Array ? [].concat(t) : t instanceof Object ? Object.assign({}, t) : t;
    }, e);
}, wx.facility = _authorize.default.facility, Array.prototype.first = function() {
    return this[0];
}, Array.prototype.last = function() {
    return this[this.length - 1];
}, Array.prototype.get = function(e) {
    return this.slice(e, e + 1)[0];
}, wx.nextTick || (wx.nextTick = function(e) {
    return wx.setTimeout(function() {
        return e();
    }, 0);
});